#include "losescene.h"
#include "config.h"
#include <QPainter>
#include "mypushbutton.h"
#include <QApplication>

LoseScene::LoseScene(QWidget *parent)
    : QWidget{parent}
{
    //初始化窗口大小
    setFixedSize(GAME_WIDTH,GAME_HEIGTH);

    //设置窗口标题
    setWindowTitle(LOSE_TITLE);

    //加载图标
    setWindowIcon(QIcon(GAME_ICON));

    MyPushButton* backBtn = new MyPushButton(BTN_BACK);
    backBtn->setParent(this);
    backBtn->move((this->width()-backBtn->width())*0.5,(this->height()-backBtn->height())*0.5);
    connect(backBtn,&MyPushButton::clicked,[=](){
        this->hide();//自身隐藏
        QApplication::quit();
    });
}

void LoseScene::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(LOSE_PATH);
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
